Data
food_consumption <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-02-18/food_consumption.csv')
food_consumption[1:15,] %>%
kable()
| Argentina |
Pork |
10.51 |
37.20 |
| Argentina |
Poultry |
38.66 |
41.53 |
| Argentina |
Beef |
55.48 |
1712.00 |
| Argentina |
Lamb & Goat |
1.56 |
54.63 |
| Argentina |
Fish |
4.36 |
6.96 |
| Argentina |
Eggs |
11.39 |
10.46 |
| Argentina |
Milk - inc. cheese |
195.08 |
277.87 |
| Argentina |
Wheat and Wheat Products |
103.11 |
19.66 |
| Argentina |
Rice |
8.77 |
11.22 |
| Argentina |
Soybeans |
0.00 |
0.00 |
| Argentina |
Nuts inc. Peanut Butter |
0.49 |
0.87 |
| Australia |
Pork |
24.14 |
85.44 |
| Australia |
Poultry |
46.12 |
49.54 |
| Australia |
Beef |
33.86 |
1044.85 |
| Australia |
Lamb & Goat |
9.87 |
345.65 |
food_consumption %>%
ggplot(aes(consumption, co2_emmission)) +
geom_point()

food_consumption %>%
ggplot(aes(consumption, co2_emmission, colour = country)) +
geom_point()

food_consumption %>%
ggplot(aes(consumption, co2_emmission, colour = country)) +
geom_point() +
theme(legend.position = "none")

food_consumption %>%
ggplot(aes(consumption, co2_emmission, colour = food_category)) +
geom_point()

food_consumption %>%
ggplot(aes(consumption, co2_emmission, colour = food_category)) +
geom_point() +
labs(title = "Co2 emmission vs Consumption",
y = "kg CO2/person/year", x = "kg/person/year")

food_consumption %>%
ggplot(aes(consumption, co2_emmission, colour = food_category)) +
geom_point() +
labs(title = expression('CO'[2]*" Emmission vs Consumption (per person per year)"),
y = expression('kg CO'[2]*"/person/year"), x = "kg/person/year",
colour = "Food Type")

From Website
‘The study analyses data from the Food and Agriculture Organization of the United Nations (FAO) to determine the quantity of produce supplied for consumption of 11 food types for all countries researched. Using CO2 emissions data, the carbon footprint per capita is then calculated for each food type.’
Quantity was recoreded, and carbon footprint calculated using this.
Look at Consumption Only
food_consumption %>%
ggplot(aes(x = food_category, y = consumption, colour = country)) +
geom_point()

# Remove legend
food_consumption %>%
ggplot(aes(x = food_category, y = consumption, colour = country)) +
geom_point() +
theme(legend.position = "none")

# Flip plot
food_consumption %>%
ggplot(aes(x = food_category, y = consumption, colour = country)) +
geom_point() +
theme(legend.position = "none") +
coord_flip()

# alternative
food_consumption %>%
ggplot(aes(y = food_category, x = consumption, colour = country)) +
geom_point() +
theme(legend.position = "none")

#jitter
food_consumption %>%
ggplot(aes(y = food_category, x = consumption, colour = country)) +
geom_jitter() +
theme(legend.position = "none")

food_consumption %>%
ggplot(aes(y = country, x = consumption, colour = food_category)) +
geom_jitter()

Summary Stats - Consumption by country
food_consumption %>%
group_by(country) %>%
summarise(average_consumption = mean(consumption)) %>%
arrange(desc(average_consumption)) %>%
head(15) %>% kable()
| Finland |
58.16273 |
| Lithuania |
50.45545 |
| Sweden |
50.00000 |
| Netherlands |
48.56091 |
| Albania |
48.43000 |
| Ireland |
47.15000 |
| Switzerland |
46.80909 |
| Italy |
46.72545 |
| Denmark |
45.37000 |
| Luxembourg |
45.26364 |
| Greece |
44.87545 |
| USA |
44.65000 |
| Norway |
44.31727 |
| France |
43.56091 |
| Maldives |
43.30273 |
food_consumption %>%
group_by(country) %>%
summarise(average_consumption = mean(consumption)) %>%
arrange(average_consumption) %>%
head(15) %>% kable()
| Rwanda |
3.670909 |
| Malawi |
4.636364 |
| Zambia |
5.191818 |
| Mozambique |
5.764545 |
| Togo |
6.756364 |
| Uganda |
7.325455 |
| Ethiopia |
7.797273 |
| Nigeria |
8.566364 |
| Zimbabwe |
8.778182 |
| Cameroon |
8.826364 |
| Tanzania |
8.984545 |
| Niger |
9.194546 |
| Ghana |
9.200909 |
| Angola |
10.544545 |
| Congo |
10.666364 |
Ireland
food_consumption %>%
filter(country == "Ireland") %>%
arrange(desc(consumption)) %>%
kable()
| Ireland |
Milk - inc. cheese |
291.86 |
415.73 |
| Ireland |
Wheat and Wheat Products |
107.98 |
20.59 |
| Ireland |
Pork |
32.40 |
114.68 |
| Ireland |
Poultry |
26.26 |
28.21 |
| Ireland |
Beef |
22.35 |
689.67 |
| Ireland |
Fish |
17.39 |
27.77 |
| Ireland |
Eggs |
8.96 |
8.23 |
| Ireland |
Lamb & Goat |
4.10 |
143.58 |
| Ireland |
Nuts inc. Peanut Butter |
4.10 |
7.26 |
| Ireland |
Rice |
3.00 |
3.84 |
| Ireland |
Soybeans |
0.25 |
0.11 |
By Food Type
food_consumption %>%
filter(food_category == "Pork") %>%
arrange(desc(consumption)) %>%
head(10) %>% kable()
| Hong Kong SAR. China |
Pork |
67.11 |
237.54 |
| Austria |
Pork |
52.56 |
186.04 |
| Germany |
Pork |
51.81 |
183.38 |
| Spain |
Pork |
48.92 |
173.15 |
| Poland |
Pork |
46.19 |
163.49 |
| Lithuania |
Pork |
45.67 |
161.65 |
| Luxembourg |
Pork |
43.58 |
154.25 |
| Croatia |
Pork |
42.79 |
151.46 |
| Czech Republic |
Pork |
41.17 |
145.72 |
| Belarus |
Pork |
40.37 |
142.89 |
food_consumption %>%
filter(food_category == "Pork") %>%
arrange(consumption) %>%
head(10) %>% kable()
| Kuwait |
Pork |
0.00 |
0.00 |
| United Arab Emirates |
Pork |
0.00 |
0.00 |
| Algeria |
Pork |
0.00 |
0.00 |
| Pakistan |
Pork |
0.00 |
0.00 |
| Saudi Arabia |
Pork |
0.00 |
0.00 |
| Tunisia |
Pork |
0.00 |
0.00 |
| Iran |
Pork |
0.00 |
0.00 |
| Bangladesh |
Pork |
0.00 |
0.00 |
| Oman |
Pork |
0.01 |
0.04 |
| Turkey |
Pork |
0.01 |
0.04 |
food_consumption %>%
filter(food_category == "Milk - inc. cheese") %>%
arrange(desc(consumption)) %>%
head(10) %>% kable()
| Finland |
Milk - inc. cheese |
430.76 |
613.57 |
| Netherlands |
Milk - inc. cheese |
341.47 |
486.39 |
| Sweden |
Milk - inc. cheese |
341.23 |
486.05 |
| Switzerland |
Milk - inc. cheese |
318.69 |
453.94 |
| Albania |
Milk - inc. cheese |
303.72 |
432.62 |
| Lithuania |
Milk - inc. cheese |
295.46 |
420.85 |
| Ireland |
Milk - inc. cheese |
291.86 |
415.73 |
| Kazakhstan |
Milk - inc. cheese |
288.12 |
410.40 |
| Estonia |
Milk - inc. cheese |
284.85 |
405.74 |
| Denmark |
Milk - inc. cheese |
277.30 |
394.99 |
food_consumption %>%
filter(food_category == "Milk - inc. cheese") %>%
arrange(consumption) %>%
head(10) %>% kable()
| Liberia |
Milk - inc. cheese |
3.04 |
4.33 |
| Cambodia |
Milk - inc. cheese |
3.47 |
4.94 |
| Mozambique |
Milk - inc. cheese |
4.79 |
6.82 |
| Sierra Leone |
Milk - inc. cheese |
7.00 |
9.97 |
| Rwanda |
Milk - inc. cheese |
7.23 |
10.30 |
| Nigeria |
Milk - inc. cheese |
7.91 |
11.27 |
| Togo |
Milk - inc. cheese |
7.96 |
11.34 |
| Malawi |
Milk - inc. cheese |
7.98 |
11.37 |
| Ghana |
Milk - inc. cheese |
9.08 |
12.93 |
| Zambia |
Milk - inc. cheese |
9.71 |
13.83 |
Map
library(maps)
world <- map_data("world")
ggplot() +
geom_polygon(data = world,
aes(x = long, y = lat, group = group), fill = NA, color = "black")

food_consumption %>%
filter(food_category == "Pork") %>%
inner_join(world, by = c("country" = "region")) -> food_consumption_map
ggplot() +
geom_polygon(data = world,
aes(x = long, y = lat, group = group), fill = NA, color = "black") +
geom_polygon(data = food_consumption_map,
aes(x = long, y = lat, group = group, fill = consumption))

library(scales)
ggplot() +
geom_polygon(data = world,
aes(x = long, y = lat, group = group), fill = NA, color = "black") +
geom_polygon(data = food_consumption_map,
aes(x = long, y = lat, group = group, fill = consumption)) +
scale_fill_distiller(palette = "Spectral", labels = number_format(suffix = " kg/person/year"))

ggplot() +
geom_polygon(data = world,
aes(x = long, y = lat, group = group), fill = NA, color = "black") +
geom_polygon(data = food_consumption_map,
aes(x = long, y = lat, group = group, fill = consumption)) +
scale_fill_distiller(palette = "Spectral", labels = number_format(suffix = " kg/person/year")) +
coord_fixed(1.3)

ggplot() +
geom_polygon(data = world,
aes(x = long, y = lat, group = group), fill = NA, color = "black") +
geom_polygon(data = food_consumption_map,
aes(x = long, y = lat, group = group, fill = consumption)) +
scale_fill_distiller(palette = "Spectral", labels = number_format(suffix = " kg/person/year")) +
coord_fixed(1.3) +
theme_void() +
theme(plot.margin = unit(c(0,0.1,0,0), "cm")) +
labs(fill = "Pork Consumption")

# unique(food_consumption$food_category)
food_type <- "Milk - inc. cheese"
food_consumption %>%
filter(food_category == food_type) %>%
inner_join(world, by = c("country" = "region")) -> food_consumption_map
ggplot() +
geom_polygon(data = world,
aes(x = long, y = lat, group = group), fill = NA, color = "black") +
geom_polygon(data = food_consumption_map,
aes(x = long, y = lat, group = group, fill = consumption)) +
scale_fill_distiller(palette = "Spectral", labels = number_format(suffix = " kg/person/year")) +
coord_fixed(1.3) +
theme_void() +
theme(plot.margin = unit(c(0,0.1,0,0), "cm")) +
labs(fill = paste0(food_type, " Consumption"))
